define(function(require, exports){
	var $		= require("jquery");
	var pubjs	= require('pubjs');
	// var util   = require('util');
	var popwin	= require('@base/dialog').base;

	var InvoiceApply = popwin.extend({
		init:function(config){
			config = pubjs.conf(config, {
				'title': LANG('备注'),
				'urlToggleUser': 'user/manualDeny',
				'width': 350,
				'silence': true,
				'view_model':{
					'DenyInfo': ''
				}
			});
			this.$param = {};

			this.Super('init', arguments);
		},
		afterBuild:function(){
			this.Super('afterBuild',arguments);
			var el = this.getDOM('body');
			el.append($([
				'<div class="P-dspUserManualDeny ml30">',
					'<div class="mb20 DenyInfoTitle">',
						'<label>'+LANG('人工启用或禁用的备注')+'</label>',
					'</div>',
					'<div class="uk-form DenyInfo">',
						'<input ms-duplex="DenyInfo">',
					'</div>',
				'</div>'
			].join('')));


			var config = {
				'invoiceApply':{
					'class': 'M-formInput mr10'
				}
			};
			this.buildFromTemplate(config);
		},
		setParam: function(param){
			this.$param = param;
		},
		getValue: function(){
			var data = this.vm.$.DenyInfo;
			return data;
		},
		reset: function(){
			this.vm.$.DenyInfo = '';
			return this;
		},
		onOk: function(){
			var self = this;
			var info = self.getValue();
			var param = this.$param;

			if(!info){
				pubjs.alert(LANG('请输入备注信息'));
				return false;
			}
			param.DenyInfo = info;
			pubjs.loading.show();
			pubjs.mc.send(self.getConfig('urlToggleUser'), param ,self.onSave.bind(self));
			return false;
		},
		onSave:function(err, data) {
			pubjs.loading.hide();
			if(err) {
				pubjs.error(err.message);
				pubjs.alert(err.message);
				return false;
			}
			this.hide();
			this.fire('toggleStatus');
		}
	});
	exports.base = InvoiceApply;

});